import os

import pytomlpp
from Plugins.tools.CommandTools import RegisterCommandNode
from Plugins.tools.InfoClasses import MSLXEvents, PluginInfo, CommandNodeInfo
from Plugins.tools.PluginTools import AddPluginInfo
from lib.log import logger


ACACIA_COMPILER_LOCATION = ""


@AddPluginInfo(PluginInfo(
    name="acacia", description="use acacia from console", author="MojaveHao", version="0.0.1"
))
def startup():
    """
    global ACACIA_COMPILER_LOCATION
    with open(os.path.abspath(os.path.join(os.getcwd(), "Config/mslx.toml")), mode='w', encoding="utf-8") as f:
        data = pytomlpp.load(f)
        acacia = data.get("Acacia", {})
        if acacia == {}:
            data.update({"Acacia": {"compiler_location": "acacia/"}})
            f.write(pytomlpp.dumps(data))
            logger.warning("Acacia编译器路径缺失")
        ACACIA_COMPILER_LOCATION = data.get("compiler_location")
    print(ACACIA_COMPILER_LOCATION)
    """